<?php
function METHOD_FUNC($method, $paras)
{
    switch($method)
    {
        case 'HELLO':
            $response="OK:";
            foreach($paras as $v)
                $response.=" $v";
            break;
        case 'ECHO':
            foreach($paras[0] as $k=>$v)
                $response[$k]=$v;
            break;
        default:
            $response="svc not found";
            break;
    }
    return $response; 
}

function main()
{
    $server=xmlrpc_server_create();
    xmlrpc_server_register_method($server, 'HELLO', 'METHOD_FUNC');
    xmlrpc_server_register_method($server, 'ECHO', 'METHOD_FUNC');
    $request=$GLOBALS['HTTP_RAW_POST_DATA'];
    $response=xmlrpc_server_call_method($server, $request, null,
            array('escaping'=>array('markup'),'encoding'=>'utf-8'));
    header("Content-Type:text/xml");
    print $response;
    xmlrpc_server_destroy($server);
}

main();
?>
